Add Content Example

The following is an example of the add content function in a template.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim m_apiObj As Ektron.Cms.UI.CommonUI.ApplicationAPI

Dim newContentId As Integer = 0

Try

m_apiObj = New Ektron.Cms.UI.CommonUI.ApplicationAPI

newContentId = m_apiObj.AddContent( _

 "admin", _

"admin", _

"", _

"Content Title", _

"Comment - this content added through API!", _

"This is the <b>body</b> of the content.", _

"This is the <i>summary</i> for the content.", _

"1033", _

"0", _

"06-27-2006 4:09 PM", _

"", _

"<metadata><meta id=""3"">ContentTitle</meta></metadata>", _

"")

Literal1.Text = "Content Added, ID = " + newContentId.ToString

Catch ex As Exception

Literal1.Text = "Error, AddContent Failed: " + ex.Message

Finally

m_apiObj = Nothing

End Try

End Sub

The previous example has the following properties:

The user “admin” is used to be authenticated.

The title of the new content block is “Content Title”.

The comment for the content is “Comment”.

The body of the content is “This is the body of the content”.

The summary of the content block is “This is the summary for the content.

The language ID = 1033, or English.

The folder ID = 0 is where the content is added.

The start date is 06-27-2006.

No end date is specified.

The metadata definition ID being set is “3” and the value is ContentTitle.

When this function is executed, the content is added to Ektron CMS400.NET. Displayed here is the record of the content in the workarea.

Previous TopicNext Topic|